package demo1;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-09
 * Time: 9:45
 */
public class TestDemo4 {

    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("text.txt")){
            byte[] bytes = new byte[1024];
            while(true){
                int len = inputStream.read(bytes);
                if(len==-1){
                    break;
                }
                String s = new String(bytes,0,len,"utf8");
                System.out.println(s);
            }
        }catch(IOException e){
            e.printStackTrace();
        }
    }

}
